<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/jsp/common/commonJs.jspf" %>
<%@ include file="/jsp/common/commonCss.jspf" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>首页</title>

<script type="text/javascript">
	$(function(){
		$('#loginBtn').click(function(){
			login();
		})
	})
	
	function login(){
		var username = $('#username').val();
		var password = $('#password').val();
		if(username == "" || password == ""){
			alert('用户名或密码不能为空');
			return;
		}
		var user = User();
		user.username = username;
		user.password = password;
		
		$.ajax({
			type: "post",
			url: "user/insert",
			data: Json.parse(user),
			success: function(result){
				alert(result.msg);
			}
		});
	}
</script>

</head>
<body>
	<form id="fm" action="user/insert" method="post">
		用户名：
		<input id="username" name="username" type="text">
		密码：
		<input id="password" name="password" type="password">
		<input id="loginBtn" type="button" value="提交"> 
	</form>
</body>
</html>